
<!-- 弹层 -->
<style type="text/css">
    #link-dialog-recommuser .modal-body .on{
        display: block;
    }
    #link-dialog-recommuser div.modal-header{
        border: none;
    }
    #link-dialog-recommuser div.modal-footer{
        border: none;
    }
    .search_btn{
        display: inline-block;
    }
    #search_result_recommuser{
        height: auto;
        overflow: hidden;
    }
    #search_result_recommuser>div{
        margin-bottom: 10px;
        overflow: hidden;
    }
    #search_result_recommuser>div>input{
        float: left;
    }
    #search_result_recommuser>div>input.url{
        width: 75%;
    }
    #search_key{
        overflow: hidden;
        width: 100%;
    }
    #search_key input{
        width: 75%;
        float: left;
    }
    #search_key button{
        float: right;
        margin-left: 20px;
    }
    span.search-result-name{
        width: 80%;
        max-width: 80%;
    }
</style>
<div class="demo">
    <div class="modal fade" id="link-dialog-recommuser" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title select_article_btn"><?php echo $this->title?></h4>
                        <ul class="nav nav-tabs" id="tab_title_div">
                        </ul>
                    </div>
                        <div class="modal-body ">

                            <div class="input-group ">
                            </div>
                            <div class="tab-content">
                                
                                <div class="tab-pane  active" id="nav-3-link-dialog">
                                    <div class="form-group">
                                        <div class="input-group" id="search_key">
                                            <input   type="text" class="form-control search_input" placeholder="请输入关键字">
                                            <button type="button" class="btn btn-primary pull-left search_btn">搜索</button>
                                        </div>
                                    </div>
                                    <div class="form-group" id="search_result_recommuser">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer clearfix">
                            <button id="sure-link-dialog sure-link-coupon" type="button" data-dismiss="modal" class="btn btn-primary" onclick="javascrtpt:linkDialogCallBackForRecommUser()">确定</button>
                            <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i>关闭</button>
                        </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
</div>
<!-- 弹层 end-->

<script type="text/javascript" src="/statics/plugins/jquery.tmpl.min.js"></script>

<script id="search_result_tmpl_recommuser" type="text/x-jquery-tmpl">
<div>
    <label class="form-control">
        <input type="radio" class="url" checked name="search-result-radio" value="${sid}" data-name="${name}" data-shopid="${shop_id}" data-shopname="${shop_name}"/>
        <span class="search-result-name">${name}--${sid}<span>
    </label>
</div>
</script>

<script type="text/javascript">
$(function(){
    $('#link-dialog-recommuser .search_btn').click(function(){
        $('#link-dialog-recommuser  #search_result_recommuser').empty();
    });
    $('#link-dialog-recommuser .search_btn').click(function(){
        var key=$("#link-dialog-recommuser .search_input").val();
        $.ajax({
                type:"GET",
                dataType: "json",
                url: "<?php echo $this->getController()->createUrl('goods/list')?>",
                data:{'keyword':key},
                success: function(json){
                    $('#search_result_recommuser').empty();
                    $("#search_result_tmpl_recommuser").tmpl(json).appendTo("#search_result_recommuser");
                },
                error:function(e){
                     $('#search_result_recommuser').empty();
                     $('#search_result_recommuser').text("没有查询到数据");
                }
            });
        return false;
    });
    //秒杀商品的搜索

});
var link_dialog_call_bakc_selecter = "#callback";

function showLinkDialogForRecommUser(selecter){
    link_dialog_call_bakc_selecter = selecter;
    $('#link-dialog-recommuser').modal('show');
}
function linkDialogCallBackForRecommUser(){
    var objs = $("#link-dialog-recommuser .tab-pane.active input.url");
    if(objs.length > 1){
        objs =  $("#link-dialog-recommuser .tab-pane.active input.url:checked")
    }
    var recommuser_sid = objs.val();
    var recommuser_name = objs.data('name');
    var data_shop_id = objs.data('shopname');
    $(link_dialog_call_bakc_selecter).val(recommuser_name);
    $(link_dialog_call_bakc_selecter).parent().find('.recomm_sid').val(recommuser_sid);
    $(link_dialog_call_bakc_selecter).validate(['required']);
    $('#data_goods_id').val(recommuser_sid);
    $('#data_shop_id').val(data_shop_id);
}
</script>
